#ifndef __CPU_H__
#define __CPU_H__
 
/*
I2C[8A]>mcu ds
Dump DP8051 SFR
SFR 80: FF 44 09 4B 00 00 00 C0 - D5 66 FF A3 FF 00 00 BF 
SFR 90: DF 04 07 00 BF 00 00 90 - 54 0D 01 01 00 90 00 BF 
SFR A0: FF BF BF BF BF BF BF BF - D7 BF BF BF BF BF BF BF 
SFR B0: 0F BF BF BF BF BF BF BF - 02 BF BF BF BF BF BF BF 
SFR C0: 50 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 BF 
SFR D0: 00 BF BF BF BF BF BF BF - 08 BF BF BF BF BF BF BF 
SFR E0: 00 BF 00 BF BF BF BF BF - 03 00 00 00 BF BF BF BF 
SFR F0: 01 BF BF BF BF BF BF BF - 00 BF 24 00 00 FF 00 BF 
I2C[8A]>mcu ws fb 4
MCU SFR Write: FB=04 (00) 00000000
I2C[8A]>mcu ds
Dump DP8051 SFR
SFR 80: FF 44 09 4B 00 00 00 C0 - D5 66 FF DA FF 00 00 BF 
SFR 90: DF 04 07 00 BF 00 00 90 - 54 0D 01 01 00 90 00 BF 
SFR A0: FF BF BF BF BF BF BF BF - F7 BF BF BF BF BF BF BF 
SFR B0: 0F BF BF BF BF BF BF BF - 02 BF BF BF BF BF BF BF 
SFR C0: 50 00 00 00 00 00 00 00 - 00 00 2E FF 3A FF 00 BF 
SFR D0: 00 BF BF BF BF BF BF BF - 08 BF BF BF BF BF BF BF 
SFR E0: 00 BF 00 BF BF BF BF BF - 03 00 00 00 BF BF BF BF 
SFR F0: 01 BF BF BF BF BF BF BF - 00 BF 20 04 00 FF 00 BF 
I2C[8A]>
I2C[8A]>
I2C[8A]>mcu ei
MCU extend Interrupt Status: 04, count: 2
I2C[8A]>
*/
 

#define RS_BUF_MAX 	32

#define	I2C_SCL		P1_0
#define	I2C_SDA		P1_1

#define PCLK_SEL_PCLK		0
#define PCLK_SEL_PLL		1
#define SPI_CK_SEL_27M		0
#define SPI_CK_SEL_32K		1
#define SPI_CK_SEL_PCLK		2
#define SPI_CK_DIV_1P0		0
#define SPI_CK_DIV_1P5		1
#define SPI_CK_DIV_2P0		2
#define SPI_CK_DIV_2P5		3

void InitCPU(void);
void EnableWatchdog(void);
void DisableWatchdog(void);
void RestartWatchdog(void);

void EnableInterrupt(BYTE intrn);
void DisableInterrupt(BYTE intrn);

BYTE RS_ready(void);
BYTE RS_rx(void);
void RS_ungetch(BYTE ch);
void RS_tx(BYTE tx_buf);

BYTE RS1_ready(void);
BYTE RS1_rx(void);
void RS1_ungetch(BYTE ch);
void RS1_tx(BYTE tx_buf);

#define ClearRemoTimer()	{ T2CON = 0x00; }
//#define	EnableRemoInt()		{ RemoDataReady = 0;	E2IE |= 0x04; }
//#define DisableRemoInt() 	{ E2IE &= 0xfb; }
#define	EnableEx14Int()		{ E2IE |= 0x80; }
#define	DisableEx14Int()	{ E2IE &= 0x7f; }

void InitRemoTimer(void);
extern	DATA 	DWORD	SystemClock;
extern  XDATA   DWORD   LastBoxMsgTime;
extern  DATA BYTE uartdata[2]; 

void delay1ms(WORD cnt);
void delay1s(WORD cnt_1s, WORD line);

void SspllSetFreqAndPll(DWORD _PPF);
void PclkoSetDiv(BYTE pol, BYTE div);
void McuSpiClkSet(BYTE PCLK_SEL,BYTE SPI_CK_SEL,BYTE SPI_CK_DIV);
void UartRun(void);
void Uart1Run(void);
void SendTouchData(WORD x, WORD y);
void sendScreenACK(BYTE mode);

#endif // __CPU_H__

